package cn.iocoder.yudao.module.member.dal.mysql.usercidbind;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.usercidbind.UserCidBindDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.app.usercidbind.vo.*;

/**
 * 推送绑定的id Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserCidBindMapper extends BaseMapperX<UserCidBindDO> {

    default PageResult<UserCidBindDO> selectPage(AppUserCidBindPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserCidBindDO>()
                .eqIfPresent(UserCidBindDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserCidBindDO::getCid, reqVO.getCid())
                .orderByDesc(UserCidBindDO::getId));
    }

    default List<UserCidBindDO> selectList(AppUserCidBindExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserCidBindDO>()
                .eqIfPresent(UserCidBindDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserCidBindDO::getCid, reqVO.getCid())
                .orderByDesc(UserCidBindDO::getId));
    }

    default int updateByUserId(Long userId,String cid){
        UserCidBindDO userCidBindDO = new UserCidBindDO();
        userCidBindDO.setCid(cid);
        return  update(userCidBindDO,new LambdaUpdateWrapper<UserCidBindDO>().eq(UserCidBindDO::getUserId,userId));
    }

}
